
// VS_BEGIN
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aCoord;
layout (location = 2) in vec3 aNormal;
layout (location = 3) in vec3 aTangent;
layout (location = 4) in vec3 aBitangent;

out vec2 Coord;

void main() {
    Coord = aCoord;
    gl_Position = vec4(aPos, 1.0f);
}
// VS_END
// FS_BEGIN
#version 330 core 

uniform sampler2D u_texture;
uniform int u_kernelSize = 2;

in vec2 Coord;

out vec4 FragColor;

void main() {
    // FragColor = vec4(vec3(1.0f - texture(u_texture, Coord).w), 1.0f);
    // FragColor = vec4(texture(u_texture, Coord).xyz, 1.0f);
    // return;
    vec2 texelSize = 1.0 / vec2(textureSize(u_texture, 0));
    vec4 color = vec4(0.0f);
    for (int x = -u_kernelSize; x < u_kernelSize; ++x) 
    {
        for (int y = -u_kernelSize; y < u_kernelSize; ++y) 
        {
            vec2 offset = vec2(float(x), float(y)) * texelSize;
            color += texture(u_texture, Coord + offset);
        }
    }
    FragColor = color / (4.0f * u_kernelSize * u_kernelSize);
}
// FS_END
